package com.suemi.missile.common.mql.query;

import com.suemi.missile.common.mql.domain.Query;
import com.suemi.missile.common.mql.domain.Select;
import com.suemi.missile.common.mql.exception.MqlFeatureNotSupportedException;
import com.suemi.missile.common.mql.exception.MqlParseException;
import com.suemi.missile.common.mql.parse.MqlLexer;
import com.suemi.missile.common.mql.parse.MqlParseVisitor;
import com.suemi.missile.common.mql.parse.MqlParser;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.elasticsearch.client.Client;

public class ESActionFactory {

  public static QueryAction create(Client client,String mql) throws MqlParseException,MqlFeatureNotSupportedException {

    Query query = MqlParseVisitor.generate(mql);
    if(query instanceof Select) {
      return new SelectQueryAction(client,(Select)query);
    } else
      throw new MqlParseException("unexpected query type!");
  }
}
